﻿// op.c 
// gcc op.c

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    system("cls");
    
	int a=5,b=3;
	
	printf("%d + %d = %d\n", a, b, a+b);
	printf("%d - %d = %d\n", a, b, a-b);
	printf("%d * %d = %d\n", a, b, a*b);
	printf("%d / %d = %d\n", a, b, a/b);
	printf("(float) %d / (float) %d = %f\n", a, b, (float)a/(float)b);
	printf("%d %% %d = %d\n", a, b, a%b);
	
	a = b++;
	printf("a = b++ , a = %d  b = %d\n", a, b);
	
	a = ++b;
	printf("a = ++b , a = %d  b = %d\n", a, b);
	
	a += 10;
	printf("a += 10 , a = %d\n", a);
	
	a -= 10;
	printf("a -= 10 , a = %d\n", a);
	
	a *= 10;
	printf("a *= 10 , a = %d\n", a);
	
	a /= 10;
	printf("a /= 10 , a = %d\n", a);
	
	a %= 3;
	printf("a %%= 3  , a = %d\n", a);	// %% 表示一個 % 文字
	
	printf("5 > 3 is %d\n", (5 > 3 ) );
	printf("5 < 3 is %d\n", (5 < 3 ) );
	printf("5 == 3 is %d\n", (5 == 3 ) );
	printf("5 != 3 is %d\n", (5 != 3 ) );
	printf("! (5 > 3) is %d\n", !(5 > 3 ) );
	printf("(5 > 3) && (50 > 30) is %d\n", (5 > 3 ) && (50 > 30) );
	printf("(5 > 3) || (3 < 5) is %d\n", (5 > 3 ) || (3 < 5) );
	
	int c = ( a > b ) ? a : b ;
	printf("a = %d , b = %d\n");
	printf("c = ( a > b ) ? a : b\n");
	printf("c = %d\n",c);
	
	system("pause");
	
    return 0;
}